package com.ruoyi.web.controller.community.electronicCommerce;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.community.domain.EcNavigate;
import com.ruoyi.community.service.ec.IEcNavigateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 社区电商Controller
 * 
 * @author ruoyi
 * @date 2021-08-15
 */
@RestController
@RequestMapping("/e-commerce/navigate")
public class EcNavigateController extends BaseController
{
    @Autowired
    private IEcNavigateService ecNavigateService;

    /**
     * 查询社区电商列表
     */
    @PreAuthorize("@ss.hasPermi('e-commerce:navigate:list')")
    @GetMapping("/list")
    public TableDataInfo list(EcNavigate ecNavigate)
    {
        startPage();
        List<EcNavigate> list = ecNavigateService.selectEcNavigateList(ecNavigate);
        return getDataTable(list);
    }

    /**
     * 导出社区电商列表
     */
    @PreAuthorize("@ss.hasPermi('e-commerce:navigate:export')")
    @Log(title = "社区电商", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(EcNavigate ecNavigate)
    {
        List<EcNavigate> list = ecNavigateService.selectEcNavigateList(ecNavigate);
        ExcelUtil<EcNavigate> util = new ExcelUtil<EcNavigate>(EcNavigate.class);
        return util.exportExcel(list, "社区电商数据");
    }

    /**
     * 获取社区电商详细信息
     */
    @PreAuthorize("@ss.hasPermi('e-commerce:navigate:query')")
    @GetMapping(value = "/{navigateId}")
    public AjaxResult getInfo(@PathVariable("navigateId") Integer navigateId)
    {
        return AjaxResult.success(ecNavigateService.selectEcNavigateById(navigateId));
    }

    /**
     * 新增社区电商
     */
    @PreAuthorize("@ss.hasPermi('e-commerce:navigate:add')")
    @Log(title = "社区电商", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EcNavigate ecNavigate)
    {
        return toAjax(ecNavigateService.insertEcNavigate(ecNavigate));
    }

    /**
     * 修改社区电商
     */
    @PreAuthorize("@ss.hasPermi('e-commerce:navigate:edit')")
    @Log(title = "社区电商", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EcNavigate ecNavigate)
    {
        return toAjax(ecNavigateService.updateEcNavigate(ecNavigate));
    }

    /**
     * 删除社区电商
     */
    @PreAuthorize("@ss.hasPermi('e-commerce:navigate:remove')")
    @Log(title = "社区电商", businessType = BusinessType.DELETE)
	@DeleteMapping("/{navigateIds}")
    public AjaxResult remove(@PathVariable Integer[] navigateIds)
    {
        return toAjax(ecNavigateService.deleteEcNavigateByIds(navigateIds));
    }
}
